package org.example;

import cn.hutool.core.util.RandomUtil;
import org.banyan.senior.idempotent.annotation.AutoDuplicateRequest;
import org.banyan.senior.idempotent.annotation.AutoIdempotent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author metalsbanyan
 * @version 1.0
 * @description: 业务接口
 * @date 2023/7/21 11:24
 */
@RestController
@AutoDuplicateRequest
public class BusinessController {

    @Value("${test.data}")
    private String test;

    private static final Logger LOGGER = LoggerFactory.getLogger(BusinessController.class);

    @AutoIdempotent(prefix = "index2")
    @GetMapping("/index2")
    public String index2() {
        return "index2请求成功";
    }

    @AutoIdempotent(prefix = "post2")
    @PostMapping("/post2")
    public String post2(@RequestBody Map<String, Object> body) {
        return "post2请求成功" + body;
    }

    @GetMapping("/no2")
    public String no2() {
        return "no2" + test;
    }

    @GetMapping("/hello")
    public String hello() {
        return RandomUtil.randomString("hello", 2);
    }
}
